<?php
/*THIS IS A PROTOTYPE AND NOT INTENDED FOR USE IN FINISHED SYSTEM*/

include_once("../info_struct.php");
include("../LDB_API/convert.php");
/*Connecting to database*/
$con = mysqli_connect("127.0.0.1", "ref", "test", "isgci");

/*Handling connection errors*/
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else
{
    $req = new infos();
    /*Get attributes from form_input.html*/
    $req->title = $_POST["title"];
    $req->year = $_POST["year"];
    $req->author = $_POST["author"];
    $req->doi = $_POST["doi"];
    $req->zmath = $_POST["zmath"];
    $req->arxiv = $_POST["arxiv"];
    $req->journal = $_POST["journal"];
    $req->volume = $_POST["volume"];
    $req->number = $_POST["number"];
    $req->pages = $_POST["pages"];
    $req->other = $_POST["other"];

    /*Handling query errors and making query*/
    $sql = infos2SqlInsert($req);
    if (!mysqli_query($con,$sql)) {
        die('Error: ' .mysqli_error($con));
    }
    /*acknowledge user in case of success*/    
    echo "Record added";
    /*close connection*/
    mysqli_close($con);
}

?>
